<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class States_mod extends CI_Model
{   
    
    private $_dbTableStates = 'states';
    /**
     *  class sonstructor
     */
    function __construct() 
	{
		// Call the Model constructor
        parent::__construct();
	}
    
    
    public function getStatesList()
    {
        $query = $this->db->select('name,code')
                          ->from($this->_dbTableStates)
                          ->where('active',1)
                          ->order_by('order','ASC')
                          ->get();
        
        //echo $this->db->last_query();
        $errors = $this->db->_error_message();
        if (!empty($errors)) {
          throw new Exception("SQL Error: " . $errors);
        } else { }

        if ($query->num_rows() > 0) {
          $result = $query->result();
          $query->free_result();
        } else {
          $result = NULL;
        }

        return $result;
    }
    
}// end class States_mod

/*
      $query = $this->db->select('*')
                        ->from()
                        ->where()
                        ->get();
      //echo $this->db->last_query();
      $errors = $this->db->_error_message();
      if (!empty($errors)) {
        throw new Exception("SQL Error: " . $errors);
      } else { }

      if ($query->num_rows() > 0) {
        $result = $query->result();
        $query->free_result();
      } else {
        $result = NULL;
      }

      return $result;
 */

// end file: application/models/states_mod.php

?>